"""Add model_used column to requirements table

Revision ID: ad3df05bec16
Revises:
Create Date: [具体日期]

"""
from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = 'ad3df05bec16'
down_revision = None
branch_labels = None
depends_on = None


def upgrade():
    with op.batch_alter_table('requirements') as batch_op:
        # 添加 model_used 列
        batch_op.add_column(sa.Column('model_used', sa.String(), nullable=True))
        # 创建外键约束并指定名称
        batch_op.create_foreign_key('fk_requirements_user_id_users_id', 'users', ['user_id'], ['id'])


def downgrade():
    with op.batch_alter_table('requirements') as batch_op:
        # 删除外键约束，使用指定的名称
        batch_op.drop_constraint('fk_requirements_user_id_users_id', type_='foreignkey')
        # 删除 model_used 列
        batch_op.drop_column('model_used')